package MySocket;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class MyServer2 {
    public static void main(String[] args) {
        try(ServerSocket serverSocket2 = new ServerSocket(10086)){
            System.out.println("等待客户端连接");
            while (true){  //无限循环，等待客户端连接
                Socket socket2 = serverSocket2.accept();
                System.out.println("客户端已连接，客户端IP地址是" + socket2.getInetAddress().getHostAddress());
            }
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
